#include <start.h>



int m_allFileCount = 0;
int m_scriptFileCount = 0;
int m_mdxFileCount = 0;
int m_picFileCount = 0;
int m_usedMdxFileCount = 0;
int m_usedPicFileCount = 0;
int m_delMdxFileCount = 0;
int m_delPicFileCount = 0;

QString m_mapDir;
QString m_resourceDir;
QString m_exePath;
QString m_mapName;
QStringList m_scriptFile;
QStringList m_usedMdxFile;
QStringList m_usedPicFile;
QStringList m_allMdxFile;
QStringList m_allPicFile;
QStringList m_whiteListMdx;
QStringList m_whiteListPic;
QStringList m_whiteListDir;
QStringList m_errorLog;
QStringList deleted_files;
/*
id有效确认步骤
1.预设可破坏物、装饰物  war3Map.doo
2.lua、jass中使用的id
3.单位预设技能id
4.单位技能id关联的魔法效果;魔法书关联的技能
*/
QStringList all_usedID; //所有出现在lua、j、war3Map.doo中的id
QStringList all_ID; //物编中所有id


void SearchFile(QString mapFile,QString w2l,QString whiteFile,bool read_slk);

void resetMeberData();
void getScriptFile(QString dirPath); //获取脚本文件
void SearchScript(); //搜索地图目录中的脚本文件中的mdx和blp.tga
void replaceChar(QString* str);
bool isInQStringList(QString str,QStringList qs);
void SearchMdx();//搜索模型中的贴图
void SearchWar3MapSkinTxt();
void SearchDoo();//搜索预设的装饰物可破坏物 wa3map.doo文件 太麻烦不想写 暂未编写
//void SearchID();//搜索脚本中出现的单位id、技能id、物品id 太麻烦不想写 暂未使用
void delImpini();//删除table中的imp.ini 这个文件会包含所有导入文件,删除并不影响地图重新打包

void delMdxPic();
void delFile(const QString &strPath);
void writeLog();





void resetMeberData()
{
     m_allFileCount = 0;
     m_scriptFileCount = 0;
     m_mdxFileCount = 0;
     m_picFileCount = 0;
     m_usedMdxFileCount = 0;
     m_usedPicFileCount = 0;
     m_delMdxFileCount = 0;
     m_delPicFileCount = 0;

     m_scriptFile.clear();
     m_usedMdxFile.clear();
     m_usedPicFile.clear();
     m_allMdxFile.clear();
     m_allPicFile.clear();
}

void replaceChar(QString* str)
{
    *str = str->replace('\'',"");
    *str = str->replace('\"',"");
    if(str->indexOf("[[")==0)
    {
        *str = str->replace("[[","");
        *str = str->replace("]]","");
    }
    *str = str->replace("\\\\","/");
    *str = str->replace("\\","/");
    *str = str->replace(".mdl",".mdx",Qt::CaseInsensitive);
}
bool isInQStringList(QString str,QStringList qs)
{
    for(int k=0; k<qs.count();k++)
    {
        if(qs.at(k).compare(str,Qt::CaseInsensitive)==0)
            return true;
    }
    return false;
}


QString map_suffix = "_ClearMap";

bool unPackW3x(QString mapFile,QString w2l)
{
    cout << "转换地图为Lni格式..."<<endl;
    QProcess p(NULL);
    QString dir_path  = mapFile;
    dir_path.replace(".w3x",map_suffix);
    QString mapfile_A = QString("\"%1\"").arg(mapFile);//加个引号处理路径中空格问题
    QString dir_path_A = QString("\"%1\"").arg(dir_path);
    QString commandStr = w2l + " lni " + mapfile_A + " " + dir_path_A;

    p.start("cmd", QStringList()<<"/c"<<commandStr);
    if(p.waitForStarted())
        p.waitForFinished();
    else
        cout << "启动cmd执行lni失败!"<<endl;

    QString strTemp=QString::fromLocal8Bit(p.readAllStandardOutput());  //获得输出
    if(!strTemp.contains("100%"))
    {
        cout << "转换地图为Lni格式-失败..."<<endl;
        return false;
    }
    return true;
}

void packW3x(QString mapFile,QString w2l,QString tartget_path,bool del_lni)
{
    mapFile = mapFile.replace(".w3x",map_suffix,Qt::CaseInsensitive);
    QString dir_path  = mapFile;
    QString mapfile_A;
    if(tartget_path.isEmpty())
        mapfile_A = QString("\"%1.w3x\"").arg(mapFile);//加个引号处理路径中空格问题
    else
        mapfile_A = QString("\"%1\"").arg(tartget_path);//加个引号处理路径中空格问题

    QString dir_path_A = QString("\"%1\"").arg(dir_path);
    QProcess p(NULL);
    QString commandStr = w2l + " obj " + dir_path_A +" " +mapfile_A;
    p.start("cmd", QStringList()<<"/c"<<commandStr);

    if(p.waitForStarted())
        p.waitForFinished();
    else
        cout << "启动cmd执行obj失败!"<<endl;



    QString strTemp=QString::fromLocal8Bit(p.readAllStandardOutput());  //获得输出
//    cout << strTemp.toStdString()<<endl;
    if(!strTemp.contains("100%")) cout << "错误:打包Obj格式失败!"<<endl;

    //删除lni格式目录
//    cout <<"del_lni:"<< del_lni<<endl;
    if(del_lni)
    {
        QDir dir(dir_path);
        if (!dir.exists())
             cout << "Lni目录不存在,删除失败!";
        else
        {
            if(dir.removeRecursively())
                cout << "Lni目录删除成功!"<<endl;
            else
                cout << "Lni目录删除失败!"<<endl;
        }
    }
}


void SearchFile(QString mapFile,QString w2l,QString whiteFile,QString target_path,bool read_slk,bool del_lni)
{
    QStringList whiteDir,whiteMdx,whitePic;
    if (!whiteFile.isEmpty())
    {
        //读取文件
        QString path = whiteFile;
        QFile file(path);
        if(file.open(QIODevice::ReadOnly | QIODevice::Text))//打开文件
        {
            QRegExp rx0("(^(-{2}|\\/{2})|(^(\\s*)(-{2}|\\/{2}))).*",Qt::CaseInsensitive);
            QRegExp rx1("(\\s*\\n)"); //过滤空行
            QRegExp reg_mdx(".*\\.(mdx|mdl)",Qt::CaseInsensitive);
            QRegExp reg_pic(".*\\.(blp|tga)",Qt::CaseInsensitive);
            QRegExp reg_n(".*\\n");
            while (!file.atEnd())
            {
                QByteArray line = file.readLine();

                if(rx1.exactMatch(line) || rx0.exactMatch(line))
                {

                    continue;
                }
                if(reg_n.exactMatch(line))
                {
                    line = line.replace(line.length()-1,2,""); //替换掉notepad文件换行符\n
                }


                if(reg_mdx.exactMatch(line))
                {

                    whiteMdx<<line;
                    continue;
                }

                if(reg_pic.exactMatch(line))
                {
                   whitePic<<line;

                     continue;
                }

                whiteDir.append(line);



            }
            file.close();

        }
    }




    int case_id=0;

    QString mapDir;
    m_exePath = QCoreApplication::applicationDirPath();
    QFileInfo mapFileInfo(mapFile);
    m_mapName = mapFileInfo.fileName();
    if(mapFileInfo.isFile())
    {

        if(read_slk)
        {
            QProcess p(NULL);
            QString commandStr1 = w2l + " config lni.read_slk=true";
            QString commandStr2 = w2l + " config obj.read_slk=true";
            p.start("cmd", QStringList()<<"/c"<<commandStr1);
            p.waitForStarted();
            p.waitForFinished();
            p.start("cmd", QStringList()<<"/c"<<commandStr2);
            p.waitForStarted();
            p.waitForFinished();
        }
        else
        {
            QProcess p(NULL);
            QString commandStr1 = w2l + " config lni.read_slk=false";
            QString commandStr2 = w2l + " config obj.read_slk=false";
            p.start("cmd", QStringList()<<"/c"<<commandStr1);
            p.waitForStarted();
            p.waitForFinished();
            p.start("cmd", QStringList()<<"/c"<<commandStr2);
            p.waitForStarted();
            p.waitForFinished();
        }
        if(unPackW3x(mapFile,w2l))
            mapDir = mapFile.replace(".w3x",map_suffix,Qt::CaseInsensitive);
        else
            case_id = 1;
    }
    if(mapFileInfo.isDir())
        case_id = 2;
    switch (case_id)
    {
        case 1:
            //

            break;
        case 2:

            break;
        default:
            resetMeberData();
            m_mapDir = mapDir;
            replaceChar(&m_mapDir);//如果用户直接复制windows下的目录默认斜线是'\',转成Qt默认的'/'.
            m_resourceDir = m_mapDir + "/resource/";

            m_whiteListMdx = whiteMdx;
            m_whiteListPic = whitePic;
            m_whiteListDir = whiteDir;

            //为白名单目录添加完整路径
            for(int i=0;i<m_whiteListDir.count();i++)
            {
                QString temp_dir = m_whiteListDir.at(i);
                replaceChar(&temp_dir);
                m_whiteListDir[i] = temp_dir;
                m_whiteListDir[i] = m_resourceDir+m_whiteListDir[i];
            }

            //将白名单模型加入使用的模型列表中
            for(int i=0;i<m_whiteListMdx.count();i++)
            {
                QString temp_mdx = m_whiteListMdx.at(i);
                replaceChar(&temp_mdx);
                m_usedMdxFile << temp_mdx;
            }



            delImpini();
            cout <<"搜索脚本文件和配置文件..."<<endl;
            getScriptFile(mapDir); //遍历获取脚本文件
            cout <<"搜索脚本中的mdx、blp、tga引用..."<<endl;
            SearchScript();
            cout <<"搜索mdx中的贴图..."<<endl;
            SearchMdx();
            cout <<"搜索自定义游戏界面贴图..."<<endl;
            SearchWar3MapSkinTxt();
            cout <<"删除未引用的模型与贴图..."<<endl;
            delMdxPic();
            cout <<"重新打包地图为Obj格式..."<<endl;
            packW3x(mapDir,w2l,target_path,del_lni);
            cout <<"输出日志...";
            writeLog();
            cout <<"\n执行完毕..."<<endl;
    }
}
void getScriptFile(QString mapDir)
{

    QDir dir(mapDir);
    if (!dir.exists()) {
        return ;
    }


    dir.setFilter(QDir::Dirs | QDir::Files);
    dir.setSorting(QDir::DirsFirst);
    QFileInfoList list = dir.entryInfoList();
    int i = 0;
    do {
        QFileInfo fileInfo = list.at(i);
        if (fileInfo.fileName() == "." || fileInfo.fileName() == "..")//||
        {
            i++;
            continue;
        }
        if (fileInfo.isDir())
        {
            bool flag = false;
            for(int i=0;i<m_whiteListDir.count();i++)
            {

                if (fileInfo.filePath() == m_whiteListDir.at(i))
                {
                    flag = true;
                    break;;
                }
            }
            if (flag)
            {
                i++;
                continue;
            }

            getScriptFile(fileInfo.filePath());
        }
        else
        {
            m_allFileCount++;
            QString filePath = QString("%1%2%3")
                    .arg(fileInfo.path())
                    .arg("/")
                    .arg(fileInfo.fileName());
            QRegExp rx(".*\\.(lua|j|fdf|ini)$",Qt::CaseInsensitive);
            if(rx.exactMatch(filePath))
            {
                m_scriptFile <<filePath;
                m_scriptFileCount++;
            }
            QRegExp rx1(".*\\.(blp|tga|)$",Qt::CaseInsensitive);
            if(rx1.exactMatch(filePath))
            {
                m_allPicFile << filePath;
                m_picFileCount++;
            }

            QRegExp rx2(".*\\.(mdx)$",Qt::CaseInsensitive);
            if(rx2.exactMatch(filePath))
            {
                m_allMdxFile << filePath;
                m_mdxFileCount++;
            }
        }
        i++;
    } while (i < list.size());


}

void SearchScript()
{
    if(m_scriptFile.isEmpty())
        return;



    for(int i=0;i < m_scriptFile.count();i++)
    {
        QString file_path = m_scriptFile.at(i);

        QFile file(file_path);

        file.open(QIODevice::ReadOnly);
        QRegExp rx0("(^(-{2}|\\/{2})|(^(\\s*)(-{2}|\\/{2}))).*",Qt::CaseInsensitive);
        QRegExp rx1("(\'|\"|\\[{2})[^\'\"]+\\.(mdx|mdl)(\'|\"|\\]{2})",Qt::CaseInsensitive);
        QRegExp rx2("(\'|\"|\\[{2})[^\'\"]+\\.(blp|tga)(\'|\"|\\]{2})",Qt::CaseInsensitive);
        QString matchstr;
        while (!file.atEnd())
        {
            QByteArray linStr = file.readLine();
            //过滤注释
            int pos = 0;
            bool isNotes= false;
            while ((pos = rx0.indexIn(linStr, pos)) != -1)
            {
                isNotes =  true;
                break;
            }
            if(isNotes) continue; //过滤注释行


            pos = 0;
            while ((pos = rx1.indexIn(linStr, pos)) != -1)
            {
                matchstr = rx1.cap();
                //删除 ' " [[ ]]
                replaceChar(&matchstr);
                //检测重复,重复的不存储
                if(!isInQStringList(matchstr,m_usedMdxFile))
                {
                    m_usedMdxFile << matchstr;
                    //加入英雄头像模型
                    QString portraitMdx = matchstr.replace(".mdx","_portrait.mdx",Qt::CaseInsensitive);
                    if(isInQStringList(m_resourceDir+portraitMdx,m_allMdxFile))
                    {
                        m_usedMdxFile << portraitMdx;
                        m_usedMdxFileCount++;
                    }
                    m_usedMdxFileCount++;
                }
                pos += rx1.matchedLength();
            }
            pos = 0;
            while ((pos = rx2.indexIn(linStr, pos)) != -1)
            {
                matchstr = rx2.cap();
                pos += rx2.matchedLength();
                replaceChar(&matchstr);
                if(!isInQStringList(matchstr,m_usedPicFile))
                {
                    m_usedPicFile << matchstr;
                    //加入暗图标
                    QString DISpic = matchstr.replace("CommandButtons/","CommandButtonsDisabled/DIS",Qt::CaseInsensitive);
                    if(isInQStringList(m_resourceDir+DISpic,m_allPicFile))
                    {
                        m_usedPicFile <<DISpic;
                        m_usedPicFileCount++;
                    }
                    m_usedPicFileCount++;

                }
            }
        }
        file.close();
    }
}
void SearchMdx()
{

    for(int i=0;i < m_usedMdxFile.count();i++)
    {
        m_usedMdxFile[i] = m_resourceDir+m_usedMdxFile[i];

        QFile file(m_usedMdxFile[i]);
        if(!file.open(QIODevice::ReadOnly))
        {
            m_errorLog << QString("打开模型失败:"+m_usedMdxFile[i]); //记录打开失败的模型
            continue;
        }
        QByteArray  data;
        data =  file.readAll();
        int k = 0;
        QString str;
        while(k<data.size())
        {
            if(data.at(k) != '\0')
                str+= data.at(k);
            else
            {
                if(!str.isEmpty())
                {
                    if(str.contains("GEOS",Qt::CaseInsensitive))
                        break;
                    if(str.contains(".blp",Qt::CaseInsensitive)||str.contains(".tga",Qt::CaseInsensitive))
                    {
                        if(!isInQStringList(str,m_usedPicFile))
                        {
                            str.replace("\\","/");
                            m_usedPicFile << str;
                            m_usedPicFileCount++;

                        }
                    }
                    str.clear();
                }
            }
            k++;
        }
        file.close();
    }
}

void SearchWar3MapSkinTxt()
{
    QString filePath = m_mapDir + "/map/war3mapskin.txt";
    QFile file(filePath);
    if (!file.open(QIODevice::ReadOnly))
    {
        m_errorLog << QString("打开'war3mapskin.txt'失败:"+filePath);
        return;
    }
    while (!file.atEnd())
    {
        QByteArray linStr = file.readLine();
        QRegExp rx1("\\=.*\\.(blp|tga)",Qt::CaseInsensitive);
        QString matchstr;
        int pos = 0;
        while ((pos = rx1.indexIn(linStr, pos)) != -1)
        {
            matchstr = rx1.cap();
            //检测重复,重复的不存储
            if(!isInQStringList(matchstr,m_usedPicFile))
            {
                matchstr.replace("=","");
                replaceChar(&matchstr);
                m_usedPicFile << matchstr;
                //加入暗图标
                m_usedPicFile << matchstr.replace("CommandButtons/","CommandButtonsDisabled/DIS",Qt::CaseInsensitive);
                m_usedPicFileCount++;

            }
            pos += rx1.matchedLength();
        }
    }
    file.close();
}
void delImpini()
{
    QString strPath;
    strPath = m_mapDir + "/table/imp.ini";
    delFile(strPath);
}
void delMdxPic()
{

    //添加白名单图片
    for(int i=0;i<m_whiteListPic.count();i++)
    {
        QString temp_pic = m_whiteListPic.at(i);
        replaceChar(&temp_pic);
        m_usedPicFile << temp_pic;
    }

    //为pic文件添加完整路径
    for(int i=0;i<m_usedPicFile.count();i++)
    {
        m_usedPicFile[i] = m_resourceDir+m_usedPicFile[i];
    }


    //删除多余的mdx blp tga
    for(int i=0;i<m_allMdxFile.count();i++)
    {
       if(!isInQStringList(m_allMdxFile.at(i),m_usedMdxFile))
       {
           delFile(m_allMdxFile.at(i));
           m_delMdxFileCount++;

       }
    }


    for(int i=0;i<m_allPicFile.count();i++)
    {
       if(!isInQStringList(m_allPicFile.at(i),m_usedPicFile))
       {
           delFile(m_allPicFile.at(i));
           m_delPicFileCount++;

       }
    }


}

void delFile(const QString &strPath)//要删除的文件路径
{
    if (strPath.isEmpty() || !QDir().exists(strPath))//是否传入了空的路径||路径是否存在
    {
        m_errorLog << ("删除文件失败:"+strPath);
        return;
    }
    QFileInfo FileInfo(strPath);
    if (FileInfo.isFile())//如果是文件
    {
        if(!QFile::remove(strPath))
        {
            m_errorLog << ("删除文件失败:"+strPath);
        }
        else
        {
            deleted_files << strPath;
        }
    }
}
//void writeLog()
//{
//    //判断日志目录是否存在,不存在则创建
//    QString log_path = m_exePath + "/日志";
//    QDir dir;
//    if (!dir.exists(log_path))
//    {
//        if(!dir.mkpath(log_path))
//        {
//            cout << "创建日志目录失败,不会生成日志!" << endl;
//            return;
//        }
//    }
//    QDateTime cur_time = QDateTime::currentDateTime();
//    QFile logFile1(m_exePath+QString("/日志/%1-%2-引用的模型图片.log").arg(m_mapName).arg(cur_time.toString("yyyy-MM-dd-HH-mm-ss")));
//    if(!logFile1.open(QIODevice::WriteOnly))
//    {
//        m_errorLog << ("日志文件打开失败!");
//    }

//    logFile1.write("\n\n\n使用的模型文件:\n");
//    for(int i=0;i<m_usedMdxFile.count();i++)
//    {
//        logFile1.write(m_usedMdxFile.at(i).toUtf8()+"\n");
//    }

//    logFile1.write("\n\n\n使用的贴图文件:\n");
//    for(int i=0;i<m_usedPicFile.count();i++)
//    {
//        logFile1.write(m_usedPicFile.at(i).toUtf8()+"\n");
//    }
//    logFile1.close();

//    QFile logFile2(m_exePath+QString("/日志/%1-%2-地图中所有的模型图片.log").arg(m_mapName).arg(cur_time.toString("yyyy-MM-dd-HH-mm-ss")));
//    if(!logFile2.open(QIODevice::WriteOnly))
//    {
//        m_errorLog << ("日志文件打开失败!");
//    }
//    logFile2.write("\n\n\n所有模型文件:\n");
//    for(int i=0;i<m_allMdxFile.count();i++)
//    {
//        logFile2.write(m_allMdxFile.at(i).toUtf8()+"\n");
//    }
//    logFile2.write("\n\n\n所有贴图文件:\n");
//    for(int i=0;i<m_allPicFile.count();i++)
//    {
//        logFile2.write(m_allPicFile.at(i).toUtf8()+"\n");
//    }
//    logFile2.close();

//    QFile logFile3(m_exePath+QString("/日志/%1-%2-警告信息.log").arg(m_mapName).arg(cur_time.toString("yyyy-MM-dd-HH-mm-ss")));
//    if(logFile3.open(QIODevice::WriteOnly))
//    {
//        logFile3.write("警告信息:\n");
//        logFile3.write("打开模型文件失败可能是脚本中使用了不存在的模型或者魔兽自带的模型:\n");
//        for(int i=0;i<m_errorLog.count();i++)
//        {
//            logFile3.write(m_errorLog.at(i).toUtf8()+"\n");
//        }
//        logFile3.close();
//    }

//    QFile logFile4(m_exePath+QString("/日志/%1-%2-删除的文件.log").arg(m_mapName).arg(cur_time.toString("yyyy-MM-dd-HH-mm-ss")));
//    if(logFile4.open(QIODevice::WriteOnly))
//    {
//        logFile4.write("删除的文件:\n");
//        for(int i=0;i<deleted_files.count();i++)
//        {
//            logFile4.write(deleted_files.at(i).toUtf8()+"\n");
//        }
//        logFile4.close();
//    }

//}

void writeLog()
{
    //判断日志目录是否存在,不存在则创建
    QString log_path = m_exePath + "/日志";
    QDir dir;
    if (!dir.exists(log_path))
    {
        if(!dir.mkpath(log_path))
        {
            cout << "创建日志目录失败,不会生成日志!" << endl;
            return;
        }
    }
    QDateTime cur_time = QDateTime::currentDateTime();
    QFile logFile(m_exePath+QString("/日志/%1-%2.log").arg(cur_time.toString("yyyy-MM-dd-HH-mm-ss")).arg(m_mapName));
    if(!logFile.open(QIODevice::WriteOnly))
    {
        cout << "日志文件打开失败!"<<endl;
    }
    else
    {
        logFile.write("------------ 警告信息 ------------\n");
        logFile.write("    打开模型失败可能是脚本中使用了不存在的模型或者魔兽自带的模型。\n");
        for(int i=0;i<m_errorLog.count();i++)
        {
            logFile.write( m_errorLog.at(i).toUtf8()+"\n");
        }

        logFile.write("\n\n\n------------ 删除文件 ------------\n");
        for(int i=0;i<deleted_files.count();i++)
        {
            logFile.write(QString("删除文件:" + deleted_files.at(i)).toUtf8()+"\n");
        }

        logFile.write("\n\n\n------------ 使用模型 ------------\n");
        for(int i=0;i<m_usedMdxFile.count();i++)
        {
            logFile.write(QString("使用模型:" + m_usedMdxFile.at(i)).toUtf8()+"\n");
        }
        logFile.write("\n\n\n------------ 使用贴图 ------------\n");
        for(int i=0;i<m_usedPicFile.count();i++)
        {
            logFile.write(QString("使用贴图:" + m_usedPicFile.at(i)).toUtf8()+"\n");
        }

        logFile.write("\n\n\n------------ 所有模型 ------------\n");
        for(int i=0;i<m_allMdxFile.count();i++)
        {
            logFile.write(QString("所有模型:" + m_allMdxFile.at(i)).toUtf8()+"\n");
        }

        logFile.write("\n\n\n------------ 所有贴图 ------------\n");
        for(int i=0;i<m_allPicFile.count();i++)
        {
            logFile.write(QString("所有贴图:" + m_allPicFile.at(i)).toUtf8()+"\n");
        }

    }

    logFile.close();

}


QString target_path;
void start(QString map_path)
{

    QTime start_time = QTime::currentTime();
//    cout << "开始时间:" << start_time.toString().toStdString()<<endl;
   //1.判断目标地图是否存在
    QFileInfo file(map_path);
    if(!file.exists())
    {
        cout<<"地图文件不存在。"<<endl;
        return;
    }

    //2.检测配置w2l.exe是否存在
    if(w2l_path.isEmpty())
    {
        cout << loss_w2l_path.toStdString()<<endl;
        return;
    }

    //3.启动执行
    SearchFile(map_path,w2l_path,whiteList,target_path,read_slk,del_lni);

    QTime end_time = QTime::currentTime();
//    cout << "结束时间:" << end_time.toString().toStdString()<<endl;
    int cost_time = start_time.msecsTo(end_time);
    cout << "用时:" << cost_time / 1000 << "秒"<<endl;
}
void start(QString map_path, QString target_file_path)
{
    QTime start_time = QTime::currentTime();

   //1.判断目标地图是否存在
    QFileInfo file(map_path);
    if(!file.exists())
    {
        cout<<"地图文件不存在。"<<endl;
        return;
    }

    //2.检测配置w2l.exe是否存在
    if(w2l_path.isEmpty())
    {
        cout << loss_w2l_path.toStdString()<<endl;
        return;
    }
    //3.启动执行
    target_path = target_file_path;
    SearchFile(map_path,w2l_path,whiteList,target_path,read_slk,del_lni);

     QTime end_time = QTime::currentTime();
     int cost_time = start_time.msecsTo(end_time);
     cout << "用时:" << cost_time / 1000 << "秒"<<endl;
}


